<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="spring" uri="/WEB-INF/tlds/spring.tld"%>
<%@ taglib prefix="c" uri="/WEB-INF/tlds/c.tld"%>
<c:set var="BasePath" value="${pageContext.request.contextPath}"></c:set>
<c:set var="Plugins" value="${pageContext.request.contextPath}/res/plugins"></c:set>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>货品规格列表</title>
<link href="${Plugins}/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
<link href="${Plugins}/ligerUI/skins/ligerui-icons.css" rel="stylesheet" type="text/css" />
<script src="${Plugins}/datepicker/WdatePicker.js" type="text/javascript"></script>
<script src="${Plugins}/jquery/jquery-1.4.4.min.js"	type="text/javascript"></script>
<script src="${Plugins}/ligerUI/js/ligerui.min.js" type="text/javascript"></script>
<script src="${BasePath}/res/js/common/utils.js" type="text/javascript"></script>
<script type="text/javascript" src="${BasePath}/res/js/ligerCommon.js"></script>
<script src="${BasePath}/res/js/product/commodityCat.js" type="text/javascript"></script>
<style type="text/css">
#searchbar{
	margin-bottom: 10px;
}
.navbar {
		height: 20px;
		border-bottom: #E6E6E6 solid 1px;
		line-height: 20px;
	}
.l-button-search{
	width: 50px;
	margin-left: 10px;
	padding-bottom: 2px;
	display: inline;
}
</style>
</head>
<body style="padding:6px; overflow:hidden;">
<div id="searchbar"><br>
	<div class="navbar"><span>您当前的位置：商品管理  &gt;规格列表 </span></div>
	<br/>
	<form action="#"  name="queryForm" id="queryForm" method="POST">
	<table>
		<tr>
			<td>规格名称：<input type="text" name="specName" id="specName" value="${specification.specName }">&nbsp;&nbsp;</td>
			<td>商品分类：</td>
			<td>
				<input type="hidden" id="catNo" name="catNo" value="${specification.catNo }">
				<div id="catDiv"></div>
			</td>
			<td><input  type="submit" value="查询" class="l-button-search" /></td>
				<td> <input type="button" id="btnReset" value="重置" class="l-button-search" /></td>
		</tr>
	
	</table>
	</form>
	<br/>
</div>
<div id="maingrid8" style="margin:0; padding:0"></div>
  <div style="display:none;">
  <!-- g data total ttt -->
</div>
<script type="text/javascript">
	var basePath="${BasePath}";
    var grid = null;
    $(function () {
    	 // 重置
        $("#btnReset").click(function(){
    		$('#searchbar :input').not(':submit, :button, :reset').val('').removeAttr('checked').removeAttr('selected');
    	});
    	
    	grid = $("#maingrid8").ligerGrid({
            columns: [
              {display:'商品分类',name:'catName' ,width: '30%'},        
             { display: '规格名称', name: 'specName',width: '40%', render: function (rowdata, rowindex, value) {
            	value = StringUtils.html_encode(value);
            	return '<span title="' + value + '">' + value + '</span>';
            } },
            { display: '操作', isSort: false, width: '30%', render: function (rowdata, rowindex, value) {
            		var h = "";
            		h += "<a href='javascript:showSpecDetail(\"" + rowdata.specNo + "\")'>修改</a>&nbsp;&nbsp;";
            		h += "<a href='javascript:deleteSpec(\"" + rowdata.specNo + "\")'>删除</a>";
            		return h;
            } }
            ], 
            pageSize:30,
            width: '100%',
            height: '100%',
            dataType: 'server', 
            dataAction: 'server',
            pagesizeParmName: 'pageSize',
            parms: [
                    {name: "specName", value:"${specification.specName }"},
                    {name: "catNo", value:"${specification.catNo }"}
            	],
            url: "ajaxToSpecList.do",
            toolbar: toolbar
        });
        
    });
    var toolbar = '';
    toolbar = {
        	items: [
        			{ text: "新增规格", click: addSpec, icon: "add" }
            		]
           		 };
    
    /**
     * 货品规格详情
     * @param poNo
     */
    function showSpecDetail(specNo) {
    	var url='../../../product/specmgt/toUpdateSpec.do?specNo=' + specNo;
    	url+="&pTabid="+WIN_TAB.getSelectedTabItemID();
    	window.parent.f_addTab('修改规格', '修改规格',url );
    }
    /**
     * 删除货品规格
     * @param poNo
     */
    function deleteSpec(specNo) {
    	$.ligerDialog.confirm('您确定要删除吗？', function (yes) { 
    	  	  if(yes){
    	  		$.post("deleteSpec.do?specNo=" + specNo, function(data) {
    	  			if(!data || data.toLowerCase() == "fail") {
    	  				window.parent.f_tip("操作失败");
    	  				return false;
    	  			} else if(data.toLowerCase() == "success") {
    	  				window.parent.f_tip("操作成功");
    	  				window.location.reload();
    	  			} else {
    	  				window.parent.f_tip(data);
    	  				return false;
    	  			}
    	  		});
    	  	} });
    }
    
    /**
     * 新增品牌信息
     */
    function addSpec(){
    	var url='../../../product/specmgt/toAddSpec.do';
    	url+="?pTabid="+WIN_TAB.getSelectedTabItemID();
    	window.parent.f_addTab('新增规格','新增规格',url);
    }
    
    var catPno = "${specification.catNo}";
    
 	// 分类初始化
    $(function() {
    	val = catPno;
    	parentCat(catPno);
    	if(val != "0")sonCat(val);
    });
 	
    function getProCat(o){
    	$("select[name=level]").eq($(o).index()).nextAll().remove();
    	if(o.value == "" || o.value == null){
    		$("#catNo").val($("select[name=level]").eq($(o).index()-1).val());
    	}else{
    		$("#catNo").val(o.value);
    		sonCat(o.value);
    	}
    	
    }
</script>
</body>
</html>